//
//  SetUpViewController.m
//  XingMei
//
//  Created by 姚琪 on 2019/3/25.
//  Copyright © 2019年 钱金军. All rights reserved.
//

#import "SetUpViewController.h"
#import "LoginViewController.h"
#import "PersonalCentreAddressManageViewController.h"//地址管理
#import "MyInfoViewController.h"
#import "WriteBankCardMessage.h"
#import "RevisePhoneNumberViewController.h"//修改手机号
#import "ReviseLoginPasswordViewController.h"
#import "RevisePayPasswordViewController.h"

@interface SetUpViewController ()<UITableViewDelegate,UITableViewDataSource>
@property(nonatomic , strong) UITableView * tableV;
@end

@implementation SetUpViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setNavTitleText:@"设置"];
    [self.view addSubview:self.tableV];
    // Do any additional setup after loading the view.
}
-(UITableView *)tableV{
    if (!_tableV) {
        _tableV = [[UITableView alloc]initWithFrame:CGRectMake(0, Height_NavBar, KScreenWidth, KScreenHeight - Height_NavBar - Height_Indicator )style:UITableViewStyleGrouped];
        _tableV.delegate = self;
        _tableV.dataSource = self;
    }
    return _tableV;
}
#pragma mark tableView DelegateAndDataSource
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    //    return self.announcementArr.count;
    return 6;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 44;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    }
    if (indexPath.row == 0) {
        cell.textLabel.text = @"个人资料设置";
    }else if (indexPath.row == 1){
       cell.textLabel.text = @"银行卡设置";
    }else if (indexPath.row == 2){
        cell.textLabel.text = @"收货地址管理";
    }else if (indexPath.row == 3){
        cell.textLabel.text = @"手机号修改";
    }else if (indexPath.row == 4){
        cell.textLabel.text = @"登录密码设置";
    }else if (indexPath.row == 5){
        cell.textLabel.text = @"支付密码设置";
    }
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    
    return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 0.0001f;
}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 30)];
    return headerView;
}
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 310)];
   UIButton* checkUpdate = [[UIButton alloc]initWithFrame:CGRectMake(50, 200, KScreenWidth - 100, 50)];
    checkUpdate.layer.cornerRadius = checkUpdate.height/2;
 
    [checkUpdate setTitle:@"退出登录" forState:0];
    checkUpdate.titleLabel.font = BoldFont(18);
    checkUpdate.backgroundColor = rgb(255,82,82);
    [checkUpdate setTitleColor:[UIColor whiteColor] forState:0];
    [checkUpdate addTarget:self action:@selector(exitToLonginViewController) forControlEvents:UIControlEventTouchUpInside];
    [headerView addSubview:checkUpdate];
 
    return headerView;
}
-(CGFloat )tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 310;
}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
    if (indexPath.row == 0) {
       // @"个人资料设置";
        MyInfoViewController *controller = [[MyInfoViewController alloc]init];
        [self.navigationController pushViewController:controller animated:YES];
    }else if (indexPath.row == 1){
       //@"银行卡设置";
        WriteBankCardMessage *controller = [[WriteBankCardMessage alloc]init];
        [self.navigationController pushViewController:controller animated:YES];
    }else if (indexPath.row == 2){
        // @"收货地址管理";
        PersonalCentreAddressManageViewController *controller = [[PersonalCentreAddressManageViewController alloc]init];
        [self.navigationController pushViewController:controller animated:YES];
    }else if (indexPath.row == 3){
        // = @"手机号修改";
        
        RevisePhoneNumberViewController *controller = [[RevisePhoneNumberViewController alloc]init];
        [self.navigationController pushViewController:controller animated:YES];
    }else if (indexPath.row == 4){
        // = @"登录密码设置";
        ReviseLoginPasswordViewController *controller = [[ReviseLoginPasswordViewController alloc]init];
        [self.navigationController pushViewController:controller animated:YES];
    }else if (indexPath.row == 5){
        // = @"支付密码设置";
        RevisePayPasswordViewController *controller = [[RevisePayPasswordViewController alloc]init];
        [self.navigationController pushViewController:controller animated:YES];
    }
}
#pragma mark- 退出登录
-(void)exitToLonginViewController{
    UIAlertController *alert=[UIAlertController alertControllerWithTitle:@"温馨提示" message:@"是否退出型美" preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction *tureAction=[UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        [self.navigationController popToRootViewControllerAnimated:YES];
//        [[NSNotificationCenter defaultCenter]postNotificationName:@"changeNumber" object:nil];
//        LoginViewController *controller = [[LoginViewController alloc]init];
//        UINavigationController * nav = [[UINavigationController alloc]initWithRootViewController:controller];
//        [DGUser setObject:@"" forKey:UserName];
//        [self presentViewController:nav animated:YES completion:nil];
        
    }];
    
    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:nil];
    [alert addAction:tureAction];
    [alert addAction:cancelAction];
    [self presentViewController:alert animated:YES completion:nil];
}





- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
